package com.cskaoyan.controller;

import com.cskaoyan.bean.bo.WxCommentPostBO;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.po.MarketComment;
import com.cskaoyan.bean.vo.wxcommentvo.WxCommentCountVO;
import com.cskaoyan.service.WxCommentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

/**
 * @author wei
 * @since 2022/09/09 10:57
 */
@RestController
@RequestMapping("wx/comment")
public class WxCommentController {
    @Autowired
    WxCommentService commentService;
//    Request URL: http://182.92.235.201:8083/wx/comment/list?
//    valueId=314&type=1&limit=20&page=1&showType=0
//Request Method: GET
//Status Code: 200
    @GetMapping("list")
    public BaseRespVo commentList(Integer valueId,byte type, int limit,int page,int showType,HttpSession session){
        CommonData commonData = commentService.queryCommentList(valueId, type, limit, page, showType,session);
        return BaseRespVo.ok(commonData);
    }
//    Request URL: http://182.92.235.201:8083/wx/comment/count?valueId=314&type=1
//Request Method: GET
//Status Code: 200
    @GetMapping("count")
    public  BaseRespVo commentCount(Integer valueId,byte type){
        WxCommentCountVO wxCommentCountVO=commentService.countComment(valueId,type);
        return BaseRespVo.ok(wxCommentCountVO);
    }

    //    Request URL: http://182.92.235.201:8083/wx/comment/post
//Request Method: POST
//Status Code: 200
    @PostMapping("post")
    public BaseRespVo commentPost(@RequestBody WxCommentPostBO wxCommentPostBO, HttpSession session) {
        commentService.postComment(wxCommentPostBO, session);
        return BaseRespVo.ok();

    }
}

